package com.guigu.www.web;

import com.guigu.www.Service.StudentService;
import com.guigu.www.pojo.Class;
import com.guigu.www.pojo.PageVo;
import com.guigu.www.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("stu")
@CrossOrigin
public class StudentController {
    @Autowired
    StudentService studentService;
    @PostMapping
    public PageVo<Student> findStudent(@RequestBody Map<String,String> map){
        System.out.println(map);
        return studentService.pageStu(map);
    }
    @GetMapping
    public List<Class> findClass(){
        return studentService.findClass();
    }
    @PutMapping
    public void updateStu(@RequestBody Student stu){
        studentService.updateByPrimaryKey(stu);
    }
    @PostMapping("/insert")
    public void insertStu(@RequestBody Student stu){
        studentService.insert(stu);
    }
    @DeleteMapping("{sid}")
    public void deleteStu(@PathVariable("sid") Integer sid){
        studentService.deleteByPrimaryKey(sid);
    }
}
